﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="CustomerManage.aspx.cs" Inherits="NetDon.OA.Portal.CRM.CustomerManage" %>

<%@ Import Namespace="NetDon.OA.Portal" %>
<%@ Register TagPrefix="uc1" TagName="GridPager" Src="~/Controls/GridPager.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">

        function createCustomer() {

            $dialog('<%= ResolveUrl(SiteUrls.CRM.CustomerInfoEdit) %>', { width: 600, height: 520 }, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }

        function modifyCustomer(type) {
            $dialog(String.format('<%=ResolveUrl(SiteUrls.CRM.CustomerInfoEdit) %>?CustomerId={0}', type), { width: 600, height: 520 }, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }

        function deleteDemand(ContactKey) {
            $confirm('确定要删除该客户信息吗?', function (result) {
                if (result) {
                    $text($get('<%=fieldCustomerId.ClientID %>'), ContactKey);
                    $get('<%=btnDeleteDemand.ClientID %>').click();
                }
            });
        }
   
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td>
                        <NetDon:FormPanel ID="PanelCondition" runat="server" CaptionAlign="NotSet" RepeatColumns="2">
                            <Items>
                                <NetDon:FormItem HeaderText="客户编号">
                                    <ContentTemplate>
                                        <asp:TextBox ID="txtCustomCode" runat="server"></asp:TextBox>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                                <NetDon:FormItem HeaderText="客户名称">
                                    <ContentTemplate>
                                        <asp:TextBox ID="txtCustomName" runat="server" MaxLength="50"></asp:TextBox>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                                <NetDon:FormItem HeaderText="联系人">
                                    <ContentTemplate>
                                        <asp:TextBox ID="txtContactName" runat="server"></asp:TextBox>
                                    </ContentTemplate>
                                </NetDon:FormItem>
                            </Items>
                        </NetDon:FormPanel>
                    </td>
                    <td valign="bottom">
                        <asp:Button runat="server" ID="btnSearch" Text="查询" OnClick="btnSearch_Click" />
                        <asp:Button runat="server" ID="btnCreateNew" Text="新增" OnClientClick="createCustomer();return false;" />
                    </td>
                </tr>
            </table>
            <div style="margin-top: 10px">
                <NetDon:GridView ID="gridCustomerInfoList" runat="server" AutoGenerateColumns="False"
                    AllowSorting="true">
                    <Columns>
                        <NetDon:BoundField HeaderText="客户编号" DataField="CustomerCode" SortExpression="CustomerCode">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="客户名称" DataField="CustomerName" SortExpression="CustomerName">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="联系人" DataField="ContactName" SortExpression="ContactName">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="电话" DataField="Phone" SortExpression="Phone">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="手机" DataField="Mobile" SortExpression="Mobile">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="电子邮箱" DataField="Email" SortExpression="Email">
                        </NetDon:BoundField>
                        <NetDon:TemplateField HeaderText="操作" ItemStyle-Width="80px">
                            <ItemTemplate>
                                <asp:ImageButton ID="btnEdit" Style="margin-left: 5px" ToolTip="Edit" runat="server"
                                    CommandName="Edit" SkinID="Modify" ImageAlign="AbsMiddle" CausesValidation="false"
                                    OnClientClick='<%# Eval("CustomerId","modifyCustomer(\"{0}\");return false;") %>' />
                                <asp:ImageButton ID="btnDelete" ToolTip="Delete" runat="server" SkinID="Delete" ImageAlign="AbsMiddle"
                                    CausesValidation="false" CommandName="DeleteCustomer" CommandArgument='<%# Eval("CustomerID") %>'
                                    OnClientClick='<%# Eval("CustomerID","deleteDemand(\"{0}\");return false;") %>' />
                            </ItemTemplate>
                        </NetDon:TemplateField>
                    </Columns>
                </NetDon:GridView>
                <asp:Button ID="btnReload" runat="server" SkinID="Hidden" OnClick="btnReload_Click" />
                <asp:HiddenField ID="fieldCustomerId" runat="server" />
                <asp:Button ID="btnDeleteDemand" runat="server" OnClick="btnDeleteDemand_Click" Text="Delete"
                    SkinID="Hidden" />
                <uc1:GridPager ID="PageQueryAdapter1" runat="server" TargetControlID="gridCustomerInfoList"
                    PageSize="20" OnPerformGetCondition="PageQueryAdapter1_PerformGetCondition" OnPerformGetRecordCount="PageQueryAdapter1_PerformGetRecordCount"
                    OnPerformGetPageData="PageQueryAdapter1_PerformGetPageData" />
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
